class CategoryMode {
  int? id;
  int? parentId;
  String? categoryName;
  String? iconUrl;
  String? advertPicUrl;
  List<CategoryMode>? children;

  CategoryMode({
    this.id,
    this.parentId,
    this.categoryName,
    this.iconUrl,
    this.advertPicUrl,
    this.children
  });

  CategoryMode.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    parentId = json['parentId'];
    categoryName = json['categoryName'];
    iconUrl = json['iconUrl'];
    advertPicUrl = json['advertPicUrl'];
    if (json['children'] != null) {
      children = <CategoryMode>[];
      json['children'].forEach((v) {
        children!.add(CategoryMode.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['parentId'] = this.parentId;
    data['categoryName'] = this.categoryName;
    data['iconUrl'] = this.iconUrl;
    data['advertPicUrl'] = this.advertPicUrl;
    final children = this.children;
    if (children != null) {
      data['children'] = children.map((v) => v.toJson()).toList();
    }
    return data;
  }

  static List<CategoryMode> formJsonList(dynamic jsonList) {
    var list = <CategoryMode>[];
    jsonList.forEach((c){
      list.add(CategoryMode.fromJson(c));
    });
    return list;
  }
}